package com.qin.mall.controller;

import com.qin.mall.common.api.CommonResult;
import com.qin.mall.service.OmsOrderSettingService;
import com.qin.mall.domain.OmsOrderSetting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/** 订单设置Controller
 * @author Leisure
 * create 2022 2022/11/10 13:36
 **/
@RestController
@RequestMapping("/orderSet")
public class OmsOrderSettingController {

    @Autowired
    private OmsOrderSettingService orderSettingService;
    
    /**
     * 获取指定订单设置
     */
    @GetMapping("/{id}")
    public CommonResult<OmsOrderSetting> orderSetting(@PathVariable Long id){
        OmsOrderSetting orderSetting = orderSettingService.getItem(id);
        return CommonResult.success(orderSetting);
    }

    /**
     * 修改指定订单设置
     */
    @PostMapping("/update/{id}")
    public CommonResult update(@PathVariable Long id,
                         @RequestBody OmsOrderSetting orderSetting){
        int count = orderSettingService.update(id, orderSetting);
        if(count>0){
            return CommonResult.success(count);
        }
        return CommonResult.failed();

    }
    
}
